﻿using MCPlatform.Dxf.Entities;
using netDxf;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MCPlatform.Dxf.Utils
{
    public class Vector3XYDistanceComparer : IComparer<PathEntityBase>
    {
        // 初始点，用于计算每个点与它的距离  
       

        public int Compare(PathEntityBase? a, PathEntityBase? b)
        {
            if (a == null || b == null) return 0;
            // 计算两个点之间的距离
            double distanceX = Vector3.Distance(a.EndPoint, b.StartPoint);
            double distanceY = Vector3.Distance(b.EndPoint, a.StartPoint);          

            // 返回距离较小的那个
            return distanceX.CompareTo(distanceY);
        }
    }
}
